﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DNADataHiding.Exceptions;

namespace DNADataHiding.Model.Shared
{
    public class ComplementRule
    {
        public static char GetComplement(char nucleotide)
        {
            switch (nucleotide)
            {
                case 'A':
                    {
                        return 'C';
                        break;
                    }
                case 'C':
                    {
                        return 'G';
                        break;
                    }
                case 'G':
                    {
                        return 'T';
                        break;
                    }
                case 'T':
                    {
                        return 'A';
                        break;
                    }
            }

            throw new ModelException(string.Format("{0} is not a valid nucleotide", nucleotide));
        }

        public static string GetComplement(string sequence)
        {
            StringBuilder sb = new StringBuilder();

            foreach (char c in sequence)
            {
                sb.Append(GetComplement(c));
            }

            return sb.ToString();
        }
    }
}
